1613A Long Comparison codeforces solution in cpp
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
main()
{
int t,i,p1,p2,c1,c2;
cin>>t;
while(t--)
{
int sx1,sx2;
string x1,x2;
cin>>x1>>p1;
cin>>x2>>p2;
sx1=x1.size()+p1;
sx2=x2.size()+p2;
if(sx1>sx2) cout<<">"<<endl;
else if(sx1<sx2) cout<<"<"<<endl;
else
{
if(p1>p2)
{
int r=p1-p2;
for(i=1;i<=r;i++) x1+='0';
c1=stoi(x1);
c2=stoi(x2);
if(c1>c2) cout<<">"<<endl;
else if(c1<c2) cout<<"<"<<endl;
else cout<<"="<<endl;
}
else
{
int r=p2-p1;
for(i=1;i<=r;i++) x2+='0';
c1=stoi(x1);
c2=stoi(x2);
if(c1>c2) cout<<">"<<endl;
else if(c1<c2) cout<<"<"<<endl;
else cout<<"="<<endl;
}
}
}
return 0;
}
0 Comments